import request from '@/utils/request'

// 查询参数列表
export function getList(query) {
  return request({
    url: '/online/online_table/page',
    method: 'get',
    headers: {
      isToken: true,
    },
    params: query
  })
}
// 添加
export function addData(data) {
  return request({
    url: '/online/online_table',
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}

//查询在线表单
export function getJSONForm(params){
  return request({
    url: '/online/onlineFrom/page',
    headers: {
      isToken: true,
    },
    method: 'get',
    params
  })
}

//新增在线表单
export function addJSONForm(data){
  return request({
    url: '/online/onlineFrom',
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}
//编辑在线表单
export function editJSONForm(data){
  return request({
    url: '/online/onlineFrom',
    headers: {
      isToken: true,
    },
    method: 'put',
    data
  })
}

//查询单表结构
export function inquireData(params){
  return request({
    url: '/common/online/getTableStructure',
    headers: {
      isToken: true,
    },
    method: 'get',
    params
  })
}

//新增列表设计
export function addTable(data){
  return request({
    url: '/online/onlineSetting',
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}
//编辑列表
export function editTable(data){
  return request({
    url: '/online/onlineSetting',
    headers: {
      isToken: true,
    },
    method: 'put',
    data
  })
}
export function viewTable(tableId){
  return request({
    url:'/online/onlineSetting/byTableId/'+tableId,
    headers: {
      isToken: true,
    },
    method: 'get',
  })
}


//在线通用新增
export function onlineAdd(url,data){
  return request({
    url: url,
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}

//在线通用编辑
export function onlineEdit(url,data){
  return request({
    url: url,
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}

//在线通用分页
export function onlineList(url,params){
  return request({
    url: url,
    headers: {
      isToken: true,
    },
    method: 'get',
    params
  })
}
// 在线删除
export function onlineDel(url,params){
  return request({
    url: url,
    headers: {
      isToken: true,
    },
    method: 'get',
    params
  })
}

// 查询数据库所有表
export function querySurfaceList(){
  return request({
    url:'/common/online/getAllTableNames',
    headers: {
      isToken: true,
    },
    method: 'get',
  })
}

//查询关联表
export function getSurfaceList(params){
  return request({
    url:'/online/onlineCorrelation/page',
    headers: {
      isToken: true,
    },
    method: 'get',
    params
  })
}

//新增关联表
export function addSurface(data){
  return request({
    url:'/online/onlineCorrelation',
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}
//编辑关联表
export function editSurface(data){
  return request({
    url:'/online/onlineCorrelation',
    headers: {
      isToken: true,
    },
    method: 'put',
    data
  })
}
//编辑关联表
export function delSurface(id){
  return request({
    url:'/online/onlineCorrelation/'+id,
    headers: {
      isToken: true,
    },
    method: 'delete',
  })
}


//查询通用详情
export function chaEditView(params){
  return request({
    url:"/common/online/info",
    headers: {
      isToken: true,
    },
    method: 'get',
    params
  })
}


//创建文件的
export function createFile(params){
  console.log(process.env.VUE_APP_FILE_URL,'process.env.VUE_APP_FILE_URL')
  return axios.get(process.env.VUE_APP_FILE_URL + '/setLocal/fileText',{
    params: {
      ...params
    },
  })
}

//创建唯一id
export function createId(){
  return request({
    url:"/online/sequence/genId",
    headers: {
      isToken: true,
    },
    method: 'get',
  })
}

//在线通用批量删除
export function getDels(data){
  return request({
    url:"/common/online/batch/del",
    headers: {
      isToken: true,
    },
    method: 'post',
    data
  })
}

//通用导出
export function exportDataList(url,data){
  return request({
    url,
    headers: {
      isToken: true,
    },
    method: 'post',
    responseType: 'blob', // 重要：指定响应类型为 blob
    data
  })
}
export function downTemplates(){
  return request({
    url:'/base/sampleList/exportTemplate',
    headers: {
      isToken: true,
    },
    method: 'post',
    responseType: 'blob', // 重要：指定响应类型为 blob
  })


}
